package com.example.demo.huawei;

import java.util.Scanner;
import java.util.StringJoiner;

/*
虚拟游戏理财
5 100 10
10 20 30 40 50
3 4 5 6 10
20 30 20 40 30
 */
public class OD55 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int p = scanner.nextInt();
        int total = scanner.nextInt();
        int risks = scanner.nextInt();

        // 回报率
        int[] arr1 = new int[p];
        for (int i = 0; i < p; i++) {
            arr1[i] = scanner.nextInt();
        }

        // 风险值
        int[] risksArr = new int[p];
        for (int i = 0; i < p; i++) {
            risksArr[i] = scanner.nextInt();
        }

        // 投资额值
        int[] totalArr = new int[p];
        for (int i = 0; i < p; i++) {
            totalArr[i] = scanner.nextInt();
        }

        //        System.out.println(Arrays.toString(arr1));
        //        System.out.println(Arrays.toString(risksArr));
        //        System.out.println(Arrays.toString(totalArr));

        int[] resArr = new int[p];
        // 两种产品
        int max = 0;
        for (int i = 0; i < p; i++) {
            for (int j = i + 1; j < p; j++) {
                // 计算两个产品是否满足要求
                // 风险值x以内 回报最大的组合
                int r = risksArr[i] + risksArr[j];
                if (r <= risks) {
                    int investmentForI, investmentForJ;
                    if (arr1[i] > arr1[j]) {
                        // 如果项目i的回报率高于项目j，优先投资项目i
                        investmentForI = Math.min(total, totalArr[i]);
                        investmentForJ = Math.min(total - investmentForI, totalArr[j]);
                    } else {
                        // 如果项目j的回报率高于项目i，优先投资项目j
                        investmentForJ = Math.min(total, totalArr[j]);
                        investmentForI = Math.min(total - investmentForJ, totalArr[i]);
                    }
                    int earn = investmentForI * arr1[i] + investmentForJ * arr1[j];
                    if (max < earn) {
                        max = earn;
                        resArr = new int[p];
                        resArr[i] = investmentForI;
                        resArr[j] = investmentForJ;
                    }
                }
            }

        }

        for (int i = 0; i < p; i++) {
            // 计算两个产品是否满足要求
            // 风险值x以内 回报最大的组合
            int r = risksArr[i];
            if (r <= risks) {
                int investmentForI = Math.min(total, totalArr[i]);
                // 计算当前回报
                int currentReturn = investmentForI * arr1[i];
                // 如果当前回报大于已知的最大回报
                if (currentReturn > max) {
                    // 更新最大回报
                    max = currentReturn;
                    // 重置最佳投资方案数组，并为项目i分配投资额
                    resArr = new int[p];
                    resArr[i] = investmentForI;
                }
            }

        }


        // 创建StringJoiner对象，用于构建输出格式
        StringJoiner sj = new StringJoiner(" ");
        // 遍历最佳投资方案数组，将投资额添加到StringJoiner中
        for (int investment : resArr) {
            sj.add(String.valueOf(investment));
        }
        System.out.println(sj.toString());
    }
}
